package com.qkjia.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;

//@Component
//public class QosListener implements ChannelAwareMessageListener {
//    @Override
//    public void onMessage(Message message, Channel channel) throws Exception {
//        Thread.sleep(1000);
//        //1.获取消息
//        System.out.println(new String(message.getBody()));
//        //3.签收
//        channel.basicAck(message.getMessageProperties().getDeliveryTag(),true);
//    }
//}
@Component
public class QosListener implements ChannelAwareMessageListener {

    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        Thread.sleep(1000);
        //1.获取消息
        System.out.println(new String(message.getBody()));
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),true);
    }
}

